package com.zeei.gis.controller;

import java.util.List;
import java.util.Properties;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageInfo;
import com.zeei.common.annotation.SysLog;
import com.zeei.common.controller.BasicController;
import com.zeei.common.enums.LogType;
import com.zeei.common.utils.PropertiesUtil;
import com.zeei.common.utils.StringUtil;
import com.zeei.common.vo.ResultDataVO;
import com.zeei.gis.service.EnterlistGisService;
import com.zeei.gis.vo.EnterlistGisVO;
import com.zeei.gis.vo.OtherConditionGisVO;

/**
 * 
* @类型名称：EnterpriseController
* @类型描述：GIS一张图
* @功能描述：GIS一张图
* @创建作者：jiangqingpeng
*
 */
@Controller
@RequestMapping("/gis/enterprise")
public class EnterlistGisController extends BasicController {

	@Autowired
	EnterlistGisService enterService;
	
	private static Properties config = null;
	
	/**
	 * 
	 * queryEnterpriseByCondition:TODO 通过名字、区域、行业、监管类别、处理工艺、污染物许可排放量查询企业信息
	 *
	 * @param pn:页码
	 * @param amount：每页显示记录数
	 * @param otherConditionGisVO
	 * @return ResultRowsVO<EnterlistGisVO>
	 */
	@RequestMapping(value="/queryCompatys", method=RequestMethod.POST)
	@ResponseBody
	@SysLog(text="通过名字、区域、行业、监管类别、处理工艺、污染物许可排放量查询企业信息", type=LogType.View)
	public ResultDataVO<PageInfo<EnterlistGisVO>> queryEnterpriseByCondition(String processTechIds, OtherConditionGisVO otherConditionGisVO) {
		List<String> list = StringUtil.splitToList(processTechIds);
		otherConditionGisVO.setProcessTechs(list);
		List<EnterlistGisVO> enterList = enterService.queryEnterpriseByCondition(otherConditionGisVO);
		PageInfo<EnterlistGisVO> listDate = new PageInfo<>(enterList, 5);
		return this.createResultDataVO(listDate, true, "");
	}
	
	@RequestMapping(value="/queryPropByKey", method=RequestMethod.POST)
	@ResponseBody
	public ResultDataVO<String> queryPropByKey(String key) {
		if(config==null) {
			config = PropertiesUtil.loadProperties("config.properties");
		}
		return this.createResultDataVO(config.getProperty(key), true, "");
	}
}
